package io.xjar;

import io.xjar.key.XKey;
import io.xjar.XKit;

import java.io.IOException;
import java.security.NoSuchAlgorithmException;

/**
 * XGo 示例程序，演示如何使用XGo生成main.go文件
 */
public class XGoExample {
    public static void main(String[] args) {
        try {
            // 使用XKit创建示例密钥
            XKey xKey = XKit.key("AES/CBC/PKCS5Padding", 128, 128, "example-password");
            
            // 使用XGo生成main.go文件
            String outputDir = "/home/daoos/IdeaProjects/xjar-plus/app/encrypted";
            String appName = "app.x";
            String jarArgs = "";
            String validStartDate = "2020-01-01 00:00:00";
            String validEndDate = "2030-12-31 23:59:59";
            String code = "EXAMPLE-CODE-12345";
            
            XGo.make(outputDir, xKey, appName, jarArgs, validStartDate, validEndDate, code);
            
            System.out.println("成功生成main.go文件到: " + outputDir);
            
        } catch (NoSuchAlgorithmException | IOException e) {
            System.err.println("生成main.go文件失败: " + e.getMessage());
            e.printStackTrace();
        }
    }
}